const express = require('express');
const router = express.Router();
const userController = require('../controllers/userController');
const questionSetController = require('../controllers/questionSetController');
const questionSetExerciseController = require('../controllers/questionSetExerciseController');

// 身份验证中间件
router.use(userController.verifyToken);

// 题库管理路由
router.post('/add', questionSetController.createQuestionSet); // 创建题库
router.get('/list', questionSetController.getQuestionSetList); // 获取用户题库列表
router.get('/detail/:id', questionSetController.getQuestionSetDetail); // 获取题库详情
router.put('/edit', questionSetController.updateQuestionSet); // 更新题库
router.delete('/delete', questionSetController.deleteQuestionSet); // 删除题库

// 题库题目管理路由
router.post('/questionsAdd', questionSetController.addQuestionToSet); // 添加题目到题库
router.put('/questionsRemove', questionSetController.removeQuestionFromSet); // 从题库移除题目

// 题库练习路由
router.post('/exercise', questionSetExerciseController.startExercise); // 开始练习
router.post('/answer', questionSetExerciseController.submitAnswer); // 提交答案
router.get('/exerciseHistory', questionSetExerciseController.getExerciseHistory); // 获取练习历史
router.get('/exercise/:exerciseId', questionSetExerciseController.getExerciseResultById); // 获取练习结果


module.exports = router; 